package io.esirong.network.retrofit;

import io.esirong.network.NetConfigs;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;

/**
 * 要做一个包装，完成隔离具体的库的实理细节
 */
public class RetrofitUtils {
    private Retrofit mRetrofit = null;
    private Retrofit mRetrofit2 = null;
    private OkHttpClient mOkHttpClient;

    public static Retrofit retrofit = null;

    public static Retrofit retrofit() {
        if (retrofit == null) {
            OkHttpClient.Builder builder = new OkHttpClient.Builder();
            /**
             *设置缓存，代码略
             */

            /**
             *  公共参数，代码略
             */

            /**
             * 设置头，代码略
             */

            /**
             * Log信息拦截器，代码略
             */

            /**
             * 设置cookie，代码略
             */

            /**
             * 设置超时和重连，代码略
             */
            //以上设置结束，才能build(),不然设置白搭
            OkHttpClient okHttpClient = builder.build();
            retrofit = new Retrofit.Builder()
                    .baseUrl(NetConfigs.BASE_URL)
                    .client(okHttpClient)
                    .build();
        }
        return retrofit;
    }
}
